#pragma once

#include <string>
#include "FreeImage/FreeImage.h"
#include "GL/glew.h"
#include "GL/glut.h"
//#include "tga.h"

#include "cubemap_util.h"

using namespace std;

class EnvironmentMap {
public:
    int size;
    GLuint cubeMap;
    GLuint cubeTextures[6];
    GLubyte* data[6];

    GLuint skyboxTextures[6];
    EnvironmentMap(const char* prefix, const char* ext);
    EnvironmentMap(int size, GLubyte* data[]);

    void setCubeMap();

    void drawSkybox(GLfloat size);

    void integrate(GLfloat& r, GLfloat& g, GLfloat& b, cubemapBRDF f, GLfloat vx, GLfloat vy, GLfloat vz, int step = 1) const;
    void integrate(GLfloat& r, GLfloat& g, GLfloat& b, cubemapWeight f) const;

    EnvironmentMap* generateDiffuseMap(int size, int step = 1) const;
    //generates a diffuse map based on http://graphics.stanford.edu/papers/envmap/
    EnvironmentMap* generateDiffuseMapY(int size) const;
};
